import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 123
 * Date: 2023-09-10
 * Time: 10:38
 */
public class Test {

    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("输入你的名字");
        String name = null ;
        name = scan.next();
        System.out.println("名字：" + name);
    }

    public static void main3(String[] args) {
        Scanner scan = new  Scanner(System.in) ;
        int a = 0 ;
        a = scan.nextInt() ;
        System.out.println("输入你的年龄");
        System.out.println("年龄："+a);
        scan.close() ;
    }

    public static void main4(String[] args) {
        Scanner scan = new Scanner(System.in) ;
        int age  = 0 ;
        String name = null ;
        System.out.println("输入你的年龄");
        age = scan.nextInt() ;
        scan.nextLine() ;
        System.out.println("年龄：" + age);
        System.out.println("输入你的姓名");
        name = scan.nextLine() ;
        System.out.println("姓名：" + name);
        scan.close();
    }

    public static void main6(String[] args) {
        Scanner scan = new Scanner(System.in) ;
        int a = 0 ;
        while(scan.hasNext()){
            a = scan.nextInt() ;
            System.out.println(a);
        }


    }

    public static void main7 (String[] args) {
        Random random = new Random() ;
        int randNum = random.nextInt(101);
        Scanner scan = new Scanner(System.in) ;
       while(true){
           System.out.println("请输入一个数字");
           int num = scan.nextInt() ;
           if(num > randNum){
               System.out.println("太大了");
           }else if(num == randNum){
               System.out.println("猜对了");
               break ;
           }else{
               System.out.println("太小了");
           }

       }
       scan.close();
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in) ;
        System.out.println("输入一个数n");
        int n = scan.nextInt() ;
        System.out.println("输入一个输m");
         int m = scan.nextInt() ;
         if(m == n) {
             System.out.println("最大公约数"+m);
         }
         if(m > n){
             if(m % n == 0){
                 System.out.println("最大公约数"+n);
             }else{
                 int sum = n-1 ;
                 while(sum >= 2){
                     if(m % sum == 0 && n % sum == 0){
                         break ;
                     }else{
                         sum -- ;
                     }

                 }
                 System.out.println("最大公约数："+sum);
             }
         }else{
             if(n % m == 0 ){
                 System.out.println("最大公约数：" + m);
             }else{
                 int sum = m - 1 ;
                 while(sum >= 2){
                     if(m % sum == 0 && n % sum == 0){
                         break ;
                     }else{
                         sum -- ;
                     }
                 }
                 System.out.println("最大公约数："+sum);;
             }
         }
    }
}
